package com.juphoon.mockdata.data.dto;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.Data;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@Data
public class E06ProductInsureDetailDTO implements BaseResponseDTO{
    @JacksonXmlProperty(localName = "PRODUCT_INTRODUCTION")
    @JsonProperty("PRODUCT_INTRODUCTION")
    private String PRODUCT_INTRODUCTION;
    @JacksonXmlProperty(localName = "AGE")
    @JsonProperty("AGE")
    private String AGE;
    @JacksonXmlProperty(localName = "TOTAL_ROWS")
    @JsonProperty("TOTAL_ROWS")
    private String TOTAL_ROWS;
    @JacksonXmlProperty(localName = "INSU_DEPT_NO")
    @JsonProperty("INSU_DEPT_NO")
    private String INSU_DEPT_NO;
    @JacksonXmlProperty(localName = "ADDI_DUTY_INFO_FLAG")
    @JsonProperty("ADDI_DUTY_INFO_FLAG")
    private String ADDI_DUTY_INFO_FLAG;
    @JacksonXmlProperty(localName = "INSURANCE_COMPANY_NAME")
    @JsonProperty("INSURANCE_COMPANY_NAME")
    private String INSURANCE_COMPANY_NAME;
    @JacksonXmlProperty(localName = "BUSI_DATE")
    @JsonProperty("BUSI_DATE")
    private String BUSI_DATE;
    @JacksonXmlProperty(localName = "SATRT_AMT")
    @JsonProperty("SATRT_AMT")
    private String SATRT_AMT;
    @JacksonXmlProperty(localName = "BLACK_LIST_FLAG")
    @JsonProperty("BLACK_LIST_FLAG")
    private String BLACK_LIST_FLAG;
    @JacksonXmlProperty(localName = "PRODUCT_ATTRIB")
    @JsonProperty("PRODUCT_ATTRIB")
    private String PRODUCT_ATTRIB;
    @JacksonXmlProperty(localName = "BATCH_ID")
    @JsonProperty("BATCH_ID")
    private String BATCH_ID;
    @JacksonXmlProperty(localName = "PRODUCT_RISK_LEVEL")
    @JsonProperty("PRODUCT_RISK_LEVEL")
    private String PRODUCT_RISK_LEVEL;
    @JacksonXmlProperty(localName = "SUB_TYPE_CODE")
    @JsonProperty("SUB_TYPE_CODE")
    private String SUB_TYPE_CODE;
    @JacksonXmlProperty(localName = "WHITE_LIST_FLAG")
    @JsonProperty("WHITE_LIST_FLAG")
    private String WHITE_LIST_FLAG;
    @JacksonXmlProperty(localName = "INSURANCE_COMPANY_FULLNAME")
    @JsonProperty("INSURANCE_COMPANY_FULLNAME")
    private String INSURANCE_COMPANY_FULLNAME;
    @JacksonXmlProperty(localName = "TYPE_CODE")
    @JsonProperty("TYPE_CODE")
    private String TYPE_CODE;
    @JacksonXmlProperty(localName = "TRAN_ARRAY")
    @JsonProperty("TRAN_ARRAY")
    private List<TranDTO> tranDTOS;
    @JacksonXmlProperty(localName = "FILE_TRANSFER_ARRAY")
    @JsonProperty("FILE_TRANSFER_ARRAY")
    private List<FileTransferDTO> fileTransferDTOs;

    public static String transferInsureChildProduct(String sub_type_code) {
        switch (sub_type_code) {
            case "A01":
            case "C01":
                return "bx_fh";
            case "A02":
            case "C02":
                return "bx_bz";
            case "A03":
            case "C03":
                return "bx_jk";
            case "A04":
            case "C04":
                return "bx_dqs";
            case "A05":
            case "C05":
                return "bx_zss";
            case "A06":
            case "C06":
                return "bx_ywsh";
            case "A07":
            case "C07":
                return "bx_lq";
            case "A08":
            case "C08":
                return "bx_nj";
            case "A09":
            case "C09":
                return "bx_wn";
            case "A10":
            case "C10":
                return "bx_tzlj";
            case "A11":
            case "C11":
            case "B10":
            case "D10":
                return "bx_qt";
            case "A12":
            case "C12":
                return "bx_jkryw";
            case "A13":
            case "C13":
                return "bx_yl";
            case "B01":
            case "D01":
                return "bx_qycc";
            case "B02":
            case "D02":
                return "bx_jdcl";
            case "B03":
            case "D03":
                return "bx_jc";
            case "B04":
            case "D04":
                return "bx_hycp";
            case "B05":
            case "D05":
                return "bx_zrbx";
            case "B06":
            case "D06":
                return "bx_jzgc";
            case "B07":
            case "D07":
                return "bx_xybx";
            case "B08":
            case "D08":
                return "bx_bzbx";
            case "B09":
            case "D09":
                return "bx_nybx";
            default:
                return null;
        }
    }

    public static String transferInsureCatName(String type_code) {
        switch (type_code) {
            case "01":
                return "财富增值保险";

            case "02":
                return "年金保险";

            case "03":
                return "寿险";

            case "04":
                return "意外保险";

            case "05":
                return "健康保险";

            case "06":
                return "两全保险";

            case "07":
                return "投连险";

            case "08":
                return "旅游保险";

            case "09":
                return "财险";
            default:
                return "";
        }
    }

    public static String transferInsureRiskLevel(String product_risk_level) {
        Pattern pattern = Pattern.compile("\\d+");
        Matcher matcher = pattern.matcher(product_risk_level);
        while (matcher.find()) {
            return "R" + (Integer.parseInt(matcher.group()) + 1);
        }
        return product_risk_level;
    }

    @Override
    public String genData() {
        System.out.println("wlk2");
        return null;
    }

    @Data
    public static class TranDTO {
        @JacksonXmlProperty(localName = "DEDCUT_YEAR_TYPE")
        @JsonProperty("DEDCUT_YEAR_TYPE")
        private String DEDCUT_YEAR_TYPE;
        @JacksonXmlProperty(localName = "INSURANCE_YEAR_TYPE")
        @JsonProperty("INSURANCE_YEAR_TYPE")
        private String INSURANCE_YEAR_TYPE;
        @JacksonXmlProperty(localName = "PRODUCT_NAME")
        @JsonProperty("PRODUCT_NAME")
        private String PRODUCT_NAME;
        @JacksonXmlProperty(localName = "PRODUCT_NO")
        @JsonProperty("PRODUCT_NO")
        private String PRODUCT_NO;
        @JacksonXmlProperty(localName = "INSURANCE_AMT")
        @JsonProperty("INSURANCE_AMT")
        private String INSURANCE_AMT;
        @JacksonXmlProperty(localName = "DEDCUT_YEARS")
        @JsonProperty("DEDCUT_YEARS")
        private String DEDCUT_YEARS;
        @JacksonXmlProperty(localName = "INSURANCE_YEARS")
        @JsonProperty("INSURANCE_YEARS")
        private String INSURANCE_YEARS;
        @JacksonXmlProperty(localName = "PRODUCT_CODE")
        @JsonProperty("PRODUCT_CODE")
        private String PRODUCT_CODE;
        @JacksonXmlProperty(localName = "INSURANCE_FEE")
        @JsonProperty("INSURANCE_FEE")
        private String INSURANCE_FEE;
        @JacksonXmlProperty(localName = "DEDCUT_MOD")
        @JsonProperty("DEDCUT_MOD")
        private String DEDCUT_MOD;
    }

    @Data
    public static class FileTransferDTO {
        @JacksonXmlProperty(localName = "FILE_TYPE")
        @JsonProperty("FILE_TYPE")
        //01: 产品主图， 02: 产品介绍, 03: 理赔流程 04: 常见问题, 05: 保险条款, 06: 投保提示书, 07: 告知事项, 08: 产品宣传折页, 09: 产品费率表, 10: 投保人声明, 11: 产品说明书, 12: 产品现金价值表
        private String FILE_TYPE;
        @JacksonXmlProperty(localName = "FILE_PATH")
        @JsonProperty("FILE_PATH")
        private String FILE_PATH;
        @JacksonXmlProperty(localName = "FILE_NAME")
        @JsonProperty("FILE_NAME")
        private String FILE_NAME;
    }
}
